#!/bin/sh

invalid_optarg ()
# $1 OPT (or OPTARG if $# -eq 1).
# $2 OPTARG
# $3+ ignored.
{
    case $# in
        0) err="Invalid OPTARG."
        1) err="Invalid OPTARG, $1."
        *) err="Invalid OPTARG, \"$2,\" passed to OPT $1."
    esac
    die "$err"
}

invalid_opt ()
# $1 OPT 
{ 
    test $# -eq 1 && err="Invalid option." \
                  || err="Invalid option, $1."
    die "$err"
}

invalid_numargs ()
# $1 should be $#.
# $2 Num args required. 
{
    case $# in
        0) err="Invalid number of args." 
        1) err="Invalid number of args, $1."
        *) err="Invalid number of args, $1. $2 required."
    esac 
    die "$err"
}

invalid_dir ()
# $1 dir path.
{
    if test $# -eq 0; then
        die "Invalid directory."
    else 
        die "Invalid directory, $1."
    fi
} 

invalid_file ()
# $1 filename.
{
    if test $# -eq 0; then
        die "Invalid file."
    else 
        die "Invalid file, $1."
    fi
} 
